<template>
  <div class="settings_box">
    <div class="bun_box">
      <div class="daoshu">
        <el-button type="primary" @click="init">查询</el-button>
      </div>
      <div class="daoshu">
        <el-button type="primary" @click="exportPdf">导出PDF</el-button>
      </div>
    </div>
    <div class="table_box">
      <el-table
          :data="tableData"
          border
          style="width: 100%">
        <el-table-column prop="code" label="设备编码"></el-table-column>
        <el-table-column prop="voltage" label="电压"></el-table-column>
        <el-table-column prop="rate" label="频率"></el-table-column>
        <el-table-column prop="j_temp" label="计算壳温"></el-table-column>
        <el-table-column prop="s_temp" label="测量壳温"></el-table-column>
        <el-table-column prop="adjust_time" label="校准时间"></el-table-column>
        <el-table-column prop="adjust_times" label="校准次数"></el-table-column>
        <el-table-column prop="monitor_time" label="监测时间"></el-table-column>
        <el-table-column prop="is_valid" label="有效标识"></el-table-column>
        <el-table-column prop="create_time" label="创建时间"></el-table-column>
        <el-table-column prop="update_time" label="更新时间"></el-table-column>
      </el-table>
      <el-pagination
          background
          layout="total, sizes, prev, pager, next, jumper"
          :page-sizes="[10, 20, 50, 100]"
          :page-size="pageSize"
          :total="total"
          :current-page="pageNo"
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
      />
    </div>
  </div>
</template>

<script>
import { tempPage } from '@/api'

export default {
  components: {},
  data () {
    return {
      tableData: [],
      pageSize: 10,
      pageNo: 1,
      total: 0,
    }
  },
  mounted () {
    this.init()
  },
  methods: {
    init() {
      tempPage({
        pageNo: this.pageNo,
        pageSize: this.pageSize,
      }).then(res => {
        if (res.code === 200) {
          console.log(res)
          this.tableData = res.data
        }
      })
    },
    handleSizeChange(e) {
      this.pageSize = e;
      this.init()
    },
    handleCurrentChange(val) {
      this.pageNo = val;
      this.init()
    },
    exportPdf() {
      window.open('http://localhost:8080/temperature/exportPdf?pageNo=' + this.pageNo + '&pageSize=' + this.pageSize)
    }
  },
}
</script>

<style scoped lang="scss">
* {
  margin: 0;
  padding: 0;
}

body {
  width: 100%;
  height: 100%;
  overflow: auto;
}

.settings_box {
  padding: 2%;
  width: 100%;
}

.bun_box {
  padding-top: 15px;
  display: flex;
  justify-content: flex-end;
}

.daoshu {
  width: 7%;
  height: 40px;
  padding-right: 15px;

  ::v-deep .el-button {
    width: 100%;
    height: 100%;
  }
}
</style>
